<template>
	<view id="page">
		<nav-bar :navH="navH" :isTabar="false" :isHome="false" :pageName="title"></nav-bar>
			<text class="t">请选择您要发布的分类</text>
			<view class="nav">
				<block v-for="(it, k1) in navs" :key="k1">
					<view class="nav-i" @click="goRelease(it.id)">
						<image :src="it.icon" mode="widthFix" lazy-load="true"></image>
						<text>{{it.type_name}}</text>
					</view>
				</block>
			</view>
	</view>
</template>

<script>
	import app from '../../common/index.js'
	export default {
		data() {
			return {
				title: '分类选择',
				navH: null,
				navs: [],
				type: null,  // 前一页传来的 发布类型(图文--1，视频--2，问答--3)
			}
		},
		onLoad(options) {
			this.navH = this.$store.state.navHeight;
			this.type = options.type;
			this.getNavs();
		},
		methods: {
			/**
			 * @des 获取分类
			 */
			getNavs() {
				app.request({
					url: 'entry/wxapp/type',
					data: {
						pagesize: 50,
					}
				}, (ret) => {
					let d = ret.data;
					this.navs = d.data;
				})
			},
			/**
			 * @des 选择分类去发布页
			 */
			goRelease(id) {
				uni.navigateTo({
					url: '../release/index?cid=' + id + '&type=' + this.type
				})
			}
		}
	}
</script>

<style>
	.t {display: block; padding: 30upx 0; border-bottom: 1px solid #ddd;}
	.nav {background-color: transparent;}
</style>
